package cn.edu.zzuli.admin.controller;

import cn.edu.zzuli.admin.service.OrderService;
import cn.edu.zzuli.common.result.Result;
import cn.edu.zzuli.common.result.ResultInfo;
import cn.edu.zzuli.model.dto.admin.OrderDetailsDto;
import cn.edu.zzuli.model.dto.admin.OrderDto;
import cn.edu.zzuli.model.vo.order.OrderChooseVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
//@CrossOrigin
@RequestMapping("/background/admin/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("orderList/{page}/{limit}")
    public ResultInfo orderList(@PathVariable Integer page,
                                @PathVariable Integer limit,
                                Integer oid){
        Page<OrderDto> orders =  orderService.queryList(page,limit,oid);
        return Result.ok(orders);
    }

    @GetMapping("details")
    public ResultInfo details(OrderChooseVo orderChooseVo){
        OrderDetailsDto order = orderService.getDetails(orderChooseVo);
        return Result.ok(order);
    }
}
